// src/mock/index.js
import Mock from 'mockjs'
import axiosMock from 'axios-mock-adapter'
import mockRequest from '@/utils/mockRequest' // 使用专用 mock 请求实例

const mock = new axiosMock(mockRequest)

// 模拟登录接口
mock.onPost('/dp-server/authority-server/oauth/token').reply(200, {
  data: {
    access_token: 'mocked-access-token',
    refresh_token: 'mocked-refresh-token'
  },
  success: true
})

// 模拟获取用户信息
mock.onGet('/dp-server/server-system/user/info').reply(200, {
  data: {
    user: {
      userName: 'testuser',
      avatar: ''
    },
    roles: ['admin'],
    permissions: ['dashboard:view', 'user:edit']
  },
  success: true
})

// 模拟菜单接口
mock.onGet('/menu/list').reply(200, {
  payload: {
    array: [
      {
        menuId: 1,
        parentId: 0,
        menuName: '仪表盘',
        menuPath: '/dashboard',
        component: 'dashboard/index',
        visible: '0',
        children: []
      },
      {
        menuId: 2,
        parentId: 0,
        menuName: '用户管理',
        menuPath: '/user',
        component: 'user/index',
        visible: '0',
        children: []
      }
    ]
  },
  success: true
})

console.log('✅ Mock 已启用')
